//
//  PlayControl.swift
//  Motion
//
//  Created by 悦月越悦 on 2021/4/1.
//

import SwiftUI

struct PlayControl: View {
    @EnvironmentObject var videoPlayModel: VideoPlayModel
    
    var body: some View {
        HStack{
            Button(action:{
                videoPlayModel.previousAction()
            }) {
                Image(systemName: "chevron.left")
                    .customFont(40, true)
                    .foregroundColor(.white)
            }
            Spacer()
            

            ToggleView ({
                Start {
                    Image(systemName: "pause.fill")
                        .customFont(40, true)
                        .foregroundColor(.white)
                }
                End {
                    Image(systemName: "chevron.right")
                        .customFont(20, true)
                        .foregroundColor(Color("topicPurple"))
                        .background(
                            Circle()
                                .fill(Color.white)
                                .frame(width: 40, height: 40)
                        )
                }
            },action1:{videoPlayModel.play = false},action2:{videoPlayModel.play = true})

            Spacer()
            Button(action:{
                videoPlayModel.nextAction()
            }) {
                Image(systemName: "chevron.right")
                    .customFont(40, true)
                    .foregroundColor(.white)
            }
        }
    }
}

struct PlayControl_Previews: PreviewProvider {
    static var previews: some View {
        PlayControl()
    }
}
